package com.bw.liveplay.common.mvvm.view.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.bw.liveplay.R
import com.bw.liveplay.common.mvvm.adapter.ViewPagerAdapter
import com.bw.liveplay.common.mvvm.view.messagefragment.FocusFragment
import com.bw.liveplay.common.mvvm.view.messagefragment.RecommentFragment
import com.flyco.tablayout.SlidingTabLayout

/**
 * @author KK
 * @description:
 * @date :2021/11/10 15:20
 *
 */
class MessageFragment : Fragment(){
    private var messageTab : SlidingTabLayout ?=null
    private var messageVip : ViewPager?=null

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {

        var inflate = inflater.inflate(R.layout.fragment_message, container, false)

        messageTab = inflate.findViewById(R.id.message_tab);
        messageVip = inflate.findViewById(R.id.message_vip);

        var fragments : ArrayList<Fragment> = ArrayList()
        var focusFragment :FocusFragment = FocusFragment()
        var recommentFragment :RecommentFragment = RecommentFragment()
        fragments.add(focusFragment)
        fragments.add(recommentFragment)
        var arr = arrayOf("关注","推荐")

        var adapter : ViewPagerAdapter = ViewPagerAdapter(childFragmentManager)
        adapter.list = fragments
        messageVip!!.adapter = adapter

        messageTab!!.setViewPager(messageVip,arr)

        return inflate
    }

}